<?php
    include 'DB.php';
    if (isset($_GET['id']))
    {
        $id = $_GET['id'];
    }
    $i = 345;
    $result = mysql_query("SELECT title,description,image,time,ID FROM news WHERE ID = $id");
    $row = mysql_fetch_row($result);
    $title1 = $row[0];
    $des = $row[1];
    $length = strlen($des);
    $showDes = substr($des,0,$i  - intval($length));
    while (substr($showDes, -1) != ' ')
    {
        $i = $i - 1;
        $showDes = substr($des,0,$i  - intval($length)); 
    }
    $showDes = $showDes."...";
    $image1 = $row[2];
    //$time1 = date("(j/n)",strtotime($row[3]));
    $date1 = date("d/m/Y",strtotime($row[3]));
    $hour = date("H:i",strtotime($row[3]));
    //$id1 = $row[4];
    echo "  <div id='titleNews'><h3>$title1</h3> </div>

            <div id='ImgDisplay'>
                <img id='newsImg' src='$image1' alt='IMG'></div>
            <div id='contentNews'>
                <span>$hour - $date1 </span><br>";
    if ($length >= $i) {
        echo $showDes;
    }
    else {
        echo $des ;
    }
    echo "<a id='ViewDetail' class='linkViewDetail'> >> Chi tiết</a>
            </div> 
            <a id='SeeMore' class='btnSeeMore'>Xem thêm</a> ";

?>
